// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   taskCycle_change_ok.java

package security.config.task;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataNumber;

public class taskCycle_change_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public taskCycle_change_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		nseer_db_backup1 security_db = new nseer_db_backup1(dbApplication);
		ValidataNumber validata = new ValidataNumber();
		try
		{
			if (security_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String task_cycle = request.getParameter("task_cycle");
				if (validata.validata(task_cycle) && Double.parseDouble(task_cycle) > 0.0D)
				{
					String sqll = "select * from security_taskcycle";
					ResultSet rs = security_db.executeQuery(sqll);
					if (rs.next())
					{
						String sql2 = (new StringBuilder("update security_taskcycle set cycle='")).append(task_cycle).append("'").toString();
						security_db.executeUpdate(sql2);
					} else
					{
						String sql3 = (new StringBuilder("insert into security_taskcycle(cycle) values('")).append(task_cycle).append("')").toString();
						security_db.executeUpdate(sql3);
					}
					response.sendRedirect("security/config/task/taskCycle_change_ok_a.jsp");
				} else
				{
					response.sendRedirect("security/config/task/taskCycle_change_ok_b.jsp");
				}
				security_db.commit();
				security_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
